﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.IO.IsolatedStorage;
using System.Windows.Media.Imaging;

namespace Yuanna
{
    public partial class YuannaShare : PhoneApplicationPage
    {
        private string pathMapFileName;

        public YuannaShare()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 进入此页面
        /// </summary>
        /// <param name="e"></param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.New)
            {
                if (NavigationContext.QueryString.ContainsKey("image_name"))
                {
                    pathMapFileName = NavigationContext.QueryString["image_name"];
                }

                textBox1.Text = "@远拿 测试....";
                BitmapImage ImageSource = new BitmapImage();

                IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
                if (file.FileExists(pathMapFileName))
                {
                    using (var myFileStream = file.OpenFile(pathMapFileName, System.IO.FileMode.Open))
                    {
                        ImageSource.SetSource(myFileStream);
                    }

                    file.Dispose();
                }

                uploadImage.Source = ImageSource;
            }
        }

        private void postAppBarButton_Click(object sender, EventArgs e)
        {
            Action<string> postCompletedCallback = (responseContent) =>
            {

                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    MessageBox.Show(responseContent);
                });
            };
        }
    }
}